home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F27874_SortByName.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  3.1 KB  |  100 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       XSLT
  4.   Sub-category:   xsl:sort
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This stylesheet demonstrates the use of xsl:sort on
  10.     alphabetic text by displaying employee information sorted
  11.     by name.
  12.  =============================================================== -->
  13. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  14.   <xsl:output method="html" />
  15.  
  16.   <xsl:template match="/">
  17.     <html>
  18.       <head>
  19.         <title>Stylesheet Example</title>
  20.         <style type="text/css"><![CDATA[
  21.         H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  22.         H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  23.         .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  24.         .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  25.         .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  26.         TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
  27.         TD {COLOR: darkblue; FONT-FAMILY: Arial}
  28.         TR { background-color: beige; }
  29.         BODY { background-color: beige; }
  30.         ]]></style>
  31.       </head>
  32.       <body>
  33.         <xsl:apply-templates />
  34.       </body>
  35.     </html>
  36.   </xsl:template>
  37.  
  38.   <xsl:template match="employees">
  39.     <h1>Sorting Employees by Name in ascending order</h1>
  40.     <table border="1">
  41.       <tr>
  42.         <th>Name</th>
  43.         <th>Department</th>
  44.         <th>Hourly Rate</th>
  45.         <th>Start Date</th>
  46.         <th>Primary Language</th>
  47.       </tr>
  48.       <xsl:for-each select="employee">
  49.         <xsl:sort order="ascending" select="employeename" />
  50.         <tr>
  51.           <td>
  52.             <xsl:value-of select="employeename" />
  53.           </td>
  54.           <td>
  55.             <xsl:value-of select="department" />
  56.           </td>
  57.           <td>
  58.             <xsl:value-of select="hourlyrate" />
  59.           </td>
  60.           <td>
  61.             <xsl:value-of select="startdate" />
  62.           </td>
  63.           <td>
  64.             <xsl:value-of select="primarylanguage" />
  65.           </td>
  66.         </tr>
  67.       </xsl:for-each>
  68.     </table>
  69.     <h1>Sorting Employees by Name in descending order</h1>
  70.     <table border="1">
  71.       <tr>
  72.         <th>Name</th>
  73.         <th>Department</th>
  74.         <th>Hourly Rate</th>
  75.         <th>Start Date</th>
  76.         <th>Primary Language</th>
  77.       </tr>
  78.       <xsl:for-each select="employee">
  79.         <xsl:sort order="descending" select="employeename" />
  80.         <tr>
  81.           <td>
  82.             <xsl:value-of select="employeename" />
  83.           </td>
  84.           <td>
  85.             <xsl:value-of select="department" />
  86.           </td>
  87.           <td>
  88.             <xsl:value-of select="hourlyrate" />
  89.           </td>
  90.           <td>
  91.             <xsl:value-of select="startdate" />
  92.           </td>
  93.           <td>
  94.             <xsl:value-of select="primarylanguage" />
  95.           </td>
  96.         </tr>
  97.       </xsl:for-each>
  98.     </table>
  99.   </xsl:template>
  100. </xsl:stylesheet>